import os
import openpyxl
from shutil import copyfile

def extract_sheet(file_path, out_path):
    #打开指定文件
    wb = openpyxl.load_workbook(file_path)
    #取sheet 名称列表
    sheetnames = wb.sheetnames

    wb.close()
    tempfile = out_path+'/t.xlsx'
    for item in sheetnames:
        copyfile(file_path, tempfile)

        wb = openpyxl.load_workbook(tempfile)
        use_less = wb.sheetnames
        use_less.remove(item)

        for i in use_less:
            wb.remove(wb[i])
        wb.save(out_path+'/'+item+'.xlsx')
        wb.close()

    os.remove(tempfile)


if __name__ == "__main__":
    extract_sheet("z:/demo.xlsx", "z:/cc")
